#coding=utf-8
__author__ = 'Meteor'

import yaml
import setings
import os

class Yam:
    def __init__(self):
        self.file = os.path.join(setings.BASE,'data','apiData.yaml')
        with open(self.file,encoding='utf-8') as fp:
            data = fp.read()
        self.data = yaml.safe_load(data)

    def info(self,api_name):
        return self.data.get(api_name)

yam = Yam()
if __name__ == '__main__':
    os.environ.update({'token':'11111111'})
    # print(yam.info('login_api').get('extract'))
    # os.environ.update({'token':'202100201'})
    # print(os.environ.get('token'))
    api = yam.info('show_user')
    print(api)
    for i in api:

        if isinstance(api.get(i),dict):
            for x, y in api.get(i).items():
                if isinstance(y,int):
                    continue
                if y.startswith('${') and y.endswith('}'):
                    print(y)
                    api.get(i).update({x:os.environ.get(y.replace("${",'').replace('}',''))})

    print(yam.info('login_api'))




